package com.zjc.redis.embedded;

import org.springframework.context.annotation.Configuration;
import redis.embedded.RedisServer;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Configuration
public class EmbeddedRedisConfig {

    private RedisServer redisServer;

    @PostConstruct
    public void launchRedis() {
        redisServer = RedisServer.builder()
                .port(6379)
                .configFile("E:\\data\\redis\\redis.conf")
                .build();
        redisServer.start();

    }

    @PreDestroy
    public void stopRedis() {
        redisServer.stop();
    }


}
